import React, { useState,useEffect } from "react";
import { NavBar } from "antd-mobile";
import { useNavigate } from "react-router-dom";
import './pingjia.css'
import axios from 'axios'

export default function Pingjia() {
  const navigate = useNavigate();
  let [shoucang, setShoucang] = useState([]);
  let shouc = async () => {
        let res = await axios.post('/linmr/getshouc',{id:localStorage.getItem('userId')})
        setShoucang(res.data.data)
        console.log(res.data.data)
     
  }
  useEffect(() => {
    shouc()
  }, [])

  return (
    <div style={{ backgroundColor: "rgb(244, 248, 255)", height: "100vh" }}>
        <div className="pingjia">
            <NavBar onBack={() =>{navigate(-1)}}>收藏</NavBar>
        </div>
        <div>
            {
                shoucang.map((item, index) => (
                    <div key={index} className='shouc'>
                        <img src={item.image[0]} alt="" />
                        <p>{item.name}</p>
                        <p>${item.price}</p>
                    </div>
                ))
            }
        </div>
    </div> 
  );
}
